package Shaders 
{	
	import flash.display.Shader;
	import flash.display.ShaderInput;
	import flash.display.ShaderParameter;
	import flash.utils.ByteArray;
	
	public class UserShader extends Shader 
	{
		private var FMetadata:Vector.<String>;
		private var FInputs:Vector.<ShaderInput>;
		private var FParameters:Vector.<ShaderParameter>;
		
		public function UserShader(code:ByteArray=null) 
		{
			super(code);			
		}
		
		public function get Name():String
		{
			return data.namespace;		
		}
		
		public function get Inputs():Vector.<ShaderInput>
		{
			if (!FInputs)
				FInputs = new Vector.<ShaderInput>;
			
			for (var Property:String in data) 
			{ 
				if (data[Property] is ShaderInput) 
				{ 
					FInputs[FInputs.length] = data[Property]; 
				} 
			}
				
			return FInputs;
		}
		
		public function get Parameters():Vector.<ShaderParameter>
		{
			if (!FParameters)
				FParameters = new Vector.<ShaderParameter>;
			
			for (var Property:String in data) 
			{ 
				if (data[Property] is ShaderParameter) 
				{ 
					FParameters[FParameters.length] = data[Property]; 
				} 
			}
				
			return FParameters;
		}
		
		public function get Metadata():Vector.<String>
		{
			if (!FMetadata)
			{
				FMetadata = new Vector.<String>;
				
				for (var Property:String in data) 
				{ 
					if (!(data[Property] is ShaderInput) && !(data[Property] is ShaderParameter)) 
					{ 
						FMetadata[FMetadata.length] = data[Property]; 
					} 
				} 
			}						
			return FMetadata;
		}
	}
}